package com.leetcode.string;

/**
 * @author Dennis Li
 * @date 2020/7/28 22:59
 */
public class IsAnagram_242 {

    public boolean isAnagram(String s, String t) {
        if (s.length() != t.length()) return false;
        char[] alphabet = new char[26];
        for (int i = 0; i < s.length(); i++) {
            int index = s.charAt(i) - '0';
            alphabet[index]++;
        }
        for (int i = 0; i < t.length(); i++) {
            int index = t.charAt(i) - '0';
            if (alphabet[index] == 0) return false;
            alphabet[index]--;
        }
        return true;
    }

}
